home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / win_utl2 / savers_.zip / BGI256.DOC next >
Text File  |  1993-04-24  |  53KB  |  1,404 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.                                   BGI256 driver
  9.                          Copyright 1991,1993 Knight Software
  10.                                 as of 17 Apr 1993
  11.  
  12.  
  13.         The BGI256 driver is a BGI driver for Super VGA cards using 
  14.         256 colors. The most popular 256 color modes are supported.
  15.         With this release of the driver, protected mode operation is now 
  16.         supported.
  17.  
  18.         Mode     Description   Memory    Who uses it
  19.          0       320x200x256 : (64K)     Standard VGA and MCGA
  20.          1       640x400x256 : (256K)    Some Super VGAs
  21.          2       640x480x256 : (512K)    Most Super VGAs
  22.          3       800x600x256 : (512K/1M) Some Super VGAs
  23.          4      1024x768x256 : (1M)      Some Super VGAs
  24.          5     1280x1024x256 : (2M)      Some Super VGAs
  25.  
  26.  
  27.         The BGI256 driver supports most of the Graphics commands with a 
  28.         few exceptions. Additionally, I have added some extensions to the 
  29.         capabilities of the BGI driver beyond the functionality of the 
  30.         standard BGI drivers. These extensions do not affect the normal 
  31.         use of the BGI driver with regular programs. The extensions allow 
  32.         for greater flexibility in the use of the driver and various 
  33.         drawing functions. 
  34.  
  35.         The driver works with the standard Borland graphics commands. For 
  36.         the operation of the graphics commands refer to your Pascal or C 
  37.         language reference manual. 
  38.  
  39.         It should be noted that the BGI driver was originally designed 
  40.         for use with the Hercules, CGA and EGA displays. It does not have 
  41.         full support capability for VGA type displays, and in fact has 
  42.         some limitations placed on it by the EGA specific code. Every 
  43.         attempt was made to keep the operation as similar as possible to 
  44.         the Borland supplied BGI drivers, but because of the limitations 
  45.         imposed by Borland's GRAPH code some functions do not work 
  46.         exactly the same, or do not work at all. 
  47.  
  48.         The following list of commands describe the exceptions or 
  49.         limitations of the graphics commands that are not fully 
  50.         supported, supported differently, or have been extended in this 
  51.         driver. Graphics functions that are not listed here continue to 
  52.         operate exactly as specified in the language reference manual. 
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.                                         1
  62.  
  63.  
  64.  
  65.         Pascal: function AutoDetect : integer;
  66.         C, C++: int huge autodetect(void);
  67.  
  68.         The AutoDetect function is not a library function but rather code 
  69.         that you must write yourself if you are going to be using 
  70.         autodetection for a non-Borland supplied BGI driver. You can 
  71.         label the function any name that you wish as long as you pass a 
  72.         pointer to the function to the InstallUserDriver when it is 
  73.         called. If you are not going to be supplying an autodetect 
  74.         function, then you should pass a nil pointer to the 
  75.         InstallUserDriver function. 
  76.  
  77.         Note: In TP5.0 and TP5.5 you must use the Autodetection method 
  78.         due to a bug in the graph unit which causes the InstallUserDriver 
  79.         function to return a bad number.
  80.  
  81.         The AutoDetect function can be used to determine if the hardware 
  82.         is installed in the computer, and the Borland manuals indicate 
  83.         that this is it's function. I consider this poor practice however 
  84.         since it places hardware dependent code in the main program which 
  85.         defeats the purpose of the BGI driver which is to remove hardware 
  86.         dependencies from the main program code. The BGI256 driver 
  87.         provides the hardware detection as a part of the driver itself. 
  88.         The detection is performed during the InitGraph (and as a side 
  89.         effect in the SetGraphMode function). 
  90.  
  91.         Normally you would pass the mode selection that you wish the 
  92.         display to start up in. Sometimes that is not always possible, 
  93.         especially with the Super VGA displays where you cannot be 
  94.         certain what modes are available until the display has been 
  95.         initialized with the InitGraph function. 
  96.  
  97.         To solve that problem, if a mode value that is outside the range 
  98.         of available modes is passed to the driver it will go into 
  99.         auto-mode detection. This will cause the driver to ignore the 
  100.         mode value and place the driver into the default mode. This 
  101.         prevents setting the display to a non-supported mode while still 
  102.         allowing the main program to be non-hardware specific. 
  103.  
  104.         The only problem with this is that the GRAPH unit will think that 
  105.         the mode selected is 127. To get around this limitation, an 
  106.         extended function has been provided to cause the GetMaxMode 
  107.         function to return the currently selected mode by calling 
  108.         SetWriteMode($E0+25) before calling GetMaxMode. The GetGraphMode 
  109.         function will not contain a proper value until a SetGraphMode 
  110.         call is made with a supported mode passed as the mode value.
  111.         Because of this, it is recommended that the GetMaxMode method be 
  112.         used if you use the auto-mode detection scheme. 
  113.  
  114.         The same effect will occur if you pass the auto-mode value as a 
  115.         mode value to the InitGraph function along with the desired 
  116.         Driver number, or if the driver is unable to select the mode that 
  117.         is passed. In all cases the grInvalidMode error will be returned.
  118.  
  119.  
  120.  
  121.  
  122.                                         2
  123.  
  124.  
  125.  
  126.         -----------------------------------------------------------------
  127.  
  128.         Pascal: procedure DetectGraph
  129.                                 (var GraphDriver, GraphMode : integer);
  130.         C, C++: void far detectgraph
  131.                             (int far *graphdriver, int far *graphmode);
  132.  
  133.         The DetectGraph function is used to detect the presence of one of 
  134.         the standard Borland supported display cards. This function will 
  135.         NOT call the AutoDetect function addressed by the 
  136.         InstallUserDriver function. If you wish to detect the presence of 
  137.         a non-Borland supplied driver, then you must first call the 
  138.         appropriate AutoDetect routine yourself.
  139.  
  140.         This function doesn't normally have to be used unless you wish to 
  141.         override the driver/mode numbers normally determined by the 
  142.         detection function and you intend to use one of the Borland 
  143.         supplied BGI drivers.
  144.  
  145.         The DetectGraph function is automatically called by the InitGraph 
  146.         function when the GraphDriver number passed is zero. If you call 
  147.         DetectGraph yourself, the number provided in GraphDriver is 
  148.         ignored, and the number for the Borland supplied driver that fits 
  149.         the determined display card is passed back in GraphDriver 
  150.         variable. The Mode number is set to the maximum mode number that 
  151.         is available for the detected display system. These numbers can 
  152.         then be used with the InitGraph function to actually initialize 
  153.         the graphics system. 
  154.  
  155.         If you wish to autodetect the BGI256 driver, then you must call 
  156.         your own AutoDetect routine to test for the driver before 
  157.         attempting to call the DetectGraph function. If you don't do 
  158.         this, then this driver will not be detected.
  159.  
  160.         See also:
  161.           AutoDetect, InitGraph, RegisterBGIdriver, InstallUserDriver
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.                                         3
  184.  
  185.  
  186.  
  187.         -----------------------------------------------------------------
  188.  
  189.         Pascal: procedure FloodFill(X, Y : integer; Border : word);
  190.         C, C++: void far floodfill(int x, int y, int border);
  191.  
  192.         The Floodfill function is now fully supported in V3.00. You can 
  193.         select either Border Fill (default), or Seed Fill operation. The 
  194.         FillPattern controls the floodfill color and pattern that will be 
  195.         used (see SetFillPattern).  Note that for Seed based fills, the 
  196.         border color passed is ignored.
  197.  
  198.         All of the extended write modes are supported by the Floodfill 
  199.         function through the use of the FillMode extension of the 
  200.         SetWriteMode command. In addition, a seperate WriteMode command 
  201.         has been provided to control specific floodfill options. 
  202.  
  203.           BorderFill ------- 0  = border fill method (default)
  204.           SeedFill --------- 1  = seed fill method
  205.           AutoFill --------- 8  = auto fill mode detection (default)
  206.           ComplexFill ------ 9  = force complex fill mode
  207.           FillCompressOff -- 10 = fast fill stack operation (default)
  208.           FillCompressOn --- 11 = compressed fill stack operation
  209.           FillDelayOff ----- 12 = draw fill lines during search (default)
  210.           FillDelayOn ------ 13 = wait until search is done to do fill
  211.           FillTracerOff ---- 14 = don't show tracer cursor (default)
  212.           FillTracerOn ----- 15 = show tracer cursor during search
  213.  
  214.         The default floodfill method is a border fill which is what 
  215.         Borland does in their own BGI drivers. Borland uses a simplex 
  216.         type of floodfill. The simplex fill is fast and uses minimum 
  217.         stack space, but it has a problem with complex fill modes (ie it 
  218.         doesn't always work). The floodfill routine provided with BGI256 
  219.         uses a simplex fill if the conditions allow it, but will switch 
  220.         to a complex fill if required to properly perform the fill. If 
  221.         you wish, you can force a complex type fill to always be used 
  222.         (it's slower and uses more stack space).
  223.  
  224.         To help alleviate the problem of running out of stack space, a 
  225.         stack compression option has been provided which reduces stack 
  226.         usage by 33% with a tradeoff of 50% reduction in fill speed.
  227.  
  228.         The FillDelay option allows the actual drawing of the fill lines 
  229.         to be delayed until after the complete search is done and all 
  230.         fill lines are known (this avoids incomplete fills because of out 
  231.         of memory problems). This option is only available in the Complex 
  232.         fill mode. It is ignored in the simplex fill mode. Since the 
  233.         fill search can take a lengthy period of time on complex fills, 
  234.         the FillTracer option is provided to show the search activity 
  235.         when using the delayed fill option (no it's not dead, just busy).
  236.  
  237.         For more information of the operation of the floodfill function, 
  238.         see the FLOOD.DOC file which contains a full description of the 
  239.         operation of the floodfill function.
  240.  
  241.  
  242.  
  243.  
  244.                                         4
  245.  
  246.  
  247.  
  248.         -----------------------------------------------------------------
  249.  
  250.         Pascal: function GetBkColor:word;
  251.         C, C++: int far getbkcolor(void);
  252.  
  253.         GetBkColor is an EGA type function. GetBkColor reads the current 
  254.         EGA type background color. See SetBkColor above for details. This 
  255.         is the last value that was set with the SetBkColor function. It 
  256.         is recommended that the SetBkColor and GetBkColor functions not 
  257.         be used. The function is mainly here for compatibility.
  258.  
  259.         See also:
  260.           SetBkColor, SetColor, GetColor, SetRGBPalette, GetMaxColor
  261.  
  262.         -----------------------------------------------------------------
  263.  
  264.         Pascal: function GetColor:word;
  265.         C, C++: int far getcolor(void);
  266.  
  267.         GetColor is the opposite of the SetColor function it returns the 
  268.         current drawing color that was set with the SetColor command.
  269.  
  270.         Note that it is not possible to read the current background color 
  271.         with this function. If you wish to keep track of the current 
  272.         background color, you should use a variable inside your 
  273.         application program to track it. 
  274.  
  275.         See also:
  276.           SetColor, SetWriteMode, GetMaxColor, GetBkColor
  277.  
  278.         -----------------------------------------------------------------
  279.  
  280.         Pascal: procedure GetDefaultPalette(var Palette : PaletteType);
  281.         C, C++: struct palettetype *far getdefaultpalette(void);
  282.  
  283.         This is an EGA type function. It will return the standard EGA 
  284.         default palette values for use with the SetAllPalette function. 
  285.         It is recommended that you do not use this function. The VGA 
  286.         palette will be loaded with a default palette whenever the 
  287.         InitGraph or SetGraphMode functions are called. You can obtain 
  288.         the default palette values by using the GetRGBPalette method 
  289.         described in the SetRGBPalette function description immediately 
  290.         after calling InitGraph or SetGraphMode. The function is mainly 
  291.         here for compatibility.
  292.  
  293.         See also:
  294.           GetPalette, GetPalette, SetAllPalette, SetRGBpalette
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.                                         5
  306.  
  307.  
  308.  
  309.         ---------------------------------------------------------------
  310.  
  311.         Pascal: function GetDriverName : string;
  312.         C, C++: char *far getdrivername(void);
  313.  
  314.         The GetDriverName returns the name of the currently loaded 
  315.         driver. Currently this function only works with Borland's C 
  316.         compilers. The Pascal GRAPH unit does not properly support this 
  317.         function and will return an empty string. To determine the driver 
  318.         name, use the GetModeName function which will return the driver 
  319.         name as a part of it's return string.
  320.  
  321.         See also:
  322.           DetectGraph, InitGraph, GetModeName
  323.  
  324.         -----------------------------------------------------------------
  325.  
  326.         Pascal: function GetGraphMode : integer;
  327.         C, C++: int far getgraphmode(void);
  328.  
  329.         The GetGraphMode function returns the currently selected display 
  330.         mode. Note that this does not call the BGI driver, thus it cannot 
  331.         know if the BGI driver is not in the mode that was declared in 
  332.         InitGraph or SetGraphMode. You can use the GetMaxMode function 
  333.         preceeded by SetWriteMode($E0+25) to obtain the currently 
  334.         selected display mode inside the BGI driver. Refer to the mode 
  335.         listing for the various mode numbers available. 
  336.  
  337.         See also:
  338.           GetMaxMode, SetGraphMode, GetGraphMode
  339.  
  340.         -----------------------------------------------------------------
  341.  
  342.         Pascal: procedure GetImage (X1, Y1, X2, Y2 : integer; 
  343.                                     var BitMap; BitBlt : word);
  344.         C, C++: void far getimage (int left, int top, int right, 
  345.                                    int bottom, void far *bitmap, int op);
  346.  
  347.         GetImage works as before, with the exception that it can be 
  348.         modified to write the data pointed at by BitMap to be replaced by 
  349.         the original display image after reading the image. This allows 
  350.         faster animation operation by eliminating several PutImage steps. 
  351.         The write method used by the GetImage function and the selection 
  352.         of the read/write or read/only mode is set with SetWriteMode 
  353.         commands. For more information on the copying methods available, 
  354.         refer to the SetWriteMode function.
  355.  
  356.         See also:
  357.            ImageSize, PutImage, SetWriteMode
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.                                         6
  367.  
  368.  
  369.  
  370.         -----------------------------------------------------------------
  371.  
  372.         Pascal: function GetMaxColor : word;
  373.         C, C++: int far getmaxcolor(void);
  374.  
  375.         This function returns the maximum color palette that can be used.
  376.         It works exactly like the normal GetMaxColor function except that 
  377.         the maximum color value of 255 will be returned instead of 15. 
  378.  
  379.         See also:
  380.           SetColor, GetColor, SetWriteMode, GetBkColor
  381.  
  382.         ---------------------------------------------------------------
  383.  
  384.         Pascal: function GetMaxMode : integer;
  385.         C, C++: int far getmaxmode(void);
  386.  
  387.         The GetMaxMode function will return the maximum mode number that 
  388.         is allowed for the card that was detected. This is typically the 
  389.         number that was passed to the InitGraph function if a non-zero 
  390.         driver number was given, or the value returned by the AutoDetect 
  391.         function if the driver number was set to zero (Detect). Refer to 
  392.         the mode listing for the various mode numbers available.
  393.  
  394.         The GetMaxMode function is also used as an mechanism to retrieve 
  395.         operation information from inside the BGI driver. The 
  396.         SetWriteMode($E0+command) function is used to select which value 
  397.         is to be returned by the GetMaxMode function for the extended 
  398.         functions. See the SetWriteMode function for more information.
  399.  
  400.         If the auto-mode detection scheme was used (passing a Mode value 
  401.         of 127 to the InitGraph function), then GetMaxMode can be used to 
  402.         find out the true currently selected mode since the GetGraphMode 
  403.         function will not return the correct value. To have GetMaxMode 
  404.         return the current mode value, preceed the call to GetMaxMode 
  405.         with a call to SetWriteMode($E0+25). 
  406.  
  407.         See also:
  408.           SetGraphMode, GetGraphMode, GetModeName, SetWriteMode
  409.  
  410.         ---------------------------------------------------------------
  411.  
  412.         Pascal: function GetModeName(GraphMode : integer) : string;
  413.         C, C++: char *far getmodename(int mode_number);
  414.  
  415.         The GetModeName function will return a string containing the mode 
  416.         and driver name for the requested mode number. An error message 
  417.         is passed back in the string if the mode requested is not 
  418.         available. The GraphResult value will also be set to 
  419.         grInvalidMode. 
  420.  
  421.         See also:
  422.           GetMaxMode, SetGraphMode, GetGraphMode, GetDriverName
  423.  
  424.  
  425.  
  426.  
  427.                                         7
  428.  
  429.  
  430.  
  431.         ---------------------------------------------------------------
  432.         Pascal: procedure GetModeRange
  433.                  (GraphDriver : integer; var LoMode, HiMode : integer);
  434.         C, C++: void far getmoderange
  435.                  (int graphdriver, int far *lomode, int far *himode);
  436.  
  437.         GetModeRange does not work with this driver. This function only 
  438.         works with Borland's predefined BGI drivers. Incorrect results 
  439.         will be returned if you use this function. This is a limitation 
  440.         of the GRAPH code, not the BGI driver. You should use the 
  441.         GetMaxMode function instead. 
  442.  
  443.         See also:
  444.           GetMaxMode, SetGraphMode, GetGraphMode, GetModeName
  445.  
  446.         -----------------------------------------------------------------
  447.         Pascal: procedure GetPalette(var Palette : PaletteType);
  448.         C, C++: void far getpalette(struc palettetype far *palette);
  449.  
  450.         This is an EGA type function. You can only get the first sixteen 
  451.         palette entry values that were previously set with the SetPalette 
  452.         or SetAllPalette functions. It is recommended that you do not use 
  453.         this function. If you need to keep track of the palette values 
  454.         you should keep a copy of the palette inside your application 
  455.         program. There is no way to directly read the palette settings 
  456.         using the BGI libraries. See the SetRGBPalette function for a 
  457.         work-around. The function is mainly here for compatibility. 
  458.  
  459.         See also:
  460.           GetDefaultPalette, GetPalette, SetAllPalette, SetRGBpalette
  461.           
  462.         -----------------------------------------------------------------
  463.         Pascal: function GetPaletteSize : integer;
  464.         C, C++: int far getpalettesize(void);
  465.  
  466.         This is an EGA type function. This function is limited by the 
  467.         GRAPH code and will always return a value of 15 which isn't much 
  468.         value in a 256 color driver.  It is recommended that you do not 
  469.         use this function. The function is mainly here for compatibility.
  470.  
  471.         See also: 
  472.           GetDefaultPalette, GetPalette, SetAllPalette, SetRGBpalette
  473.  
  474.         -----------------------------------------------------------------
  475.         Pascal: procedure GetPixel (X,Y : integer): integer;
  476.         C, C++: unsigned far getimage (int X, int Y);
  477.  
  478.         GetPixel works as before, with the exception that it can be 
  479.         modified to write the current drawing color (see SetColor) to the 
  480.         display after reading the specified pixel.  A SetWriteMode 
  481.         command controls the operation of the GetPixel function.
  482.  
  483.         See also:
  484.            ImageSize, PutImage, SetWriteMode
  485.  
  486.  
  487.  
  488.                                         8
  489.  
  490.  
  491.  
  492.         ---------------------------------------------------------------
  493.  
  494.         Pascal: procedure InitGraph(var GraphDriver : integer;
  495.                        var GraphMode : integer; PathToDriver : String);
  496.         C, C++: void far initgraph(int far *graphdriver, 
  497.                            int far *graphmode, char far *pathtodriver);
  498.  
  499.         InitGraph is used to initialize the graphics driver and switch 
  500.         the screen to graphics mode. If the GraphDriver value passed is 
  501.         zero, then the InitGraph routine will attempt to determine the 
  502.         highest display card/driver combination available. 
  503.  
  504.         If you are using a non-Borland BGI and you have provided an 
  505.         AutoDetect function (by previously calling the InstallUserDriver 
  506.         function), the InitGraph function will first call the AutoDetect 
  507.         function to see if the card exists. If the card is not found, 
  508.         then the standard Borland BGI driver detection (DetectGraph 
  509.         function) will be performed. If a Borland supported driver/card 
  510.         combination is found, then the driver and mode numbers for that 
  511.         combination will be returned.
  512.  
  513.         If the GraphNumber provided is a positive number, then it is 
  514.         assumed to be a valid driver number and that driver will be used. 
  515.         For a non-Borland supplied driver the number used should be the 
  516.         one returned by the InstallUserDriver function. 
  517.  
  518.         If a GraphNumber is provided to the InitGraph function, the 
  519.         display will be set to the mode specified in the GraphMode 
  520.         variable. If the InitGraph function is told to autodetect the 
  521.         driver/card, then the mode number will be set based on the mode 
  522.         number returned by the autodetect routine and any number passed 
  523.         in the GraphMode variable is ignored. 
  524.  
  525.         To override the default GraphMode number but still be able to 
  526.         autodetect, call any AutoDetect functions in your code yourself 
  527.         followed by the DetectGraph function if the AutoDetect function 
  528.         fails to determine the driver/card combination. Next call the 
  529.         InitGraph function with the driver and mode numbers returned from 
  530.         the detection code. 
  531.  
  532.         If you pass a GraphMode number other than the one returned by the 
  533.         autodetection function, then that will become the selected mode 
  534.         that will be used until you call SetGraphMode or the CloseGraph 
  535.         function and recall the InitGraph with a different number.
  536.  
  537.         Note that the Mode number that is passed to the InitGraph 
  538.         function is assumed to be a valid mode number that the display 
  539.         can handle. If the driver cannot support the mode, then it may 
  540.         select a different mode, and/or pass back a mode error. At this 
  541.         point, the value returned by GetGraphMode will be wrong. See the 
  542.         AutoDetect function for more information about this action.
  543.  
  544.         See also:
  545.           AutoDetect, DetectGraph, RegisterBGIdriver, InstallUserDriver
  546.  
  547.  
  548.  
  549.                                         9
  550.  
  551.  
  552.  
  553.         ---------------------------------------------------------------
  554.  
  555.         Pascal: function InstallUserDriver
  556.           (DriverFileName : string; AutoDetectPtr : pointer) : integer;
  557.         C, C++: int far installuserdriver
  558.                               (char far *name, int huge(*detect)(void);
  559.  
  560.         The InstallUserDriver function tells the program that you are 
  561.         installing a non-Borland BGI driver. This function must be called 
  562.         before calling the InitGraph routine. If you are using the 
  563.         RegisterBGIdriver function, you must use the InstallUserDriver 
  564.         function before calling the RegisterBGIdriver function. 
  565.  
  566.         The AutoDetectPtr is Pascal FAR procedure or C huge pointer that 
  567.         points to a procedure that is used to detect the presence of the 
  568.         display card being used with the driver. If the display card is 
  569.         found, then the function should return the desired mode number 
  570.         for the card. If the card is not found it should return a -2 
  571.         indicating that the card was not found. 
  572.  
  573.         Note: In TP5.0 and TP5.5 the InstallUserDriver function does not 
  574.         return a valid driver number that can be used by the InitGraph 
  575.         function. Therefore you must use the AutoDetect mechanism with 
  576.         the InitGraph function to be able to use a non-Borland supplied 
  577.         BGI driver.
  578.  
  579.         The Mode number that is returned from the function is assumed to 
  580.         be the desired mode number for the display. If you wish to use 
  581.         the display at a mode number that is not the value returned, then 
  582.         you should call the SetGraphMode function after the InitGraph 
  583.         function call to set the desired display mode.
  584.  
  585.         The AutoDetectPtr value can alternately be set to a 'nil' value 
  586.         if you do not wish to provide an autodetect function for the 
  587.         card. If you do not provide an autodetect function, then you MUST 
  588.         provide the driver number returned by InstallUserDriver to the 
  589.         InitGraph function as the driver number to use if you want the 
  590.         user supplied driver to be used. (With TP5.0 and TP5.5 you must 
  591.         provide a valid pointer, the 'nil' mechanism will not work.)
  592.  
  593.         If you tell the InitGraph function to autodetect (GraphDriver=0) 
  594.         without an autodetect function available, the InitGraph routine 
  595.         will only call the standard GraphDetect function to search for 
  596.         the standard Borland display/card combinations.
  597.              
  598.         See also:
  599.           DetectGraph, InitGraph, RegisterBGIdriver 
  600.  
  601.  
  602.  
  603.  
  604.  
  605.  
  606.  
  607.  
  608.  
  609.  
  610.                                        10
  611.  
  612.  
  613.  
  614.         -----------------------------------------------------------------
  615.  
  616.         Pascal: procedure PutImage
  617.                           (X, Y : integer; var BitMap; BitBlt : word);
  618.         C, C++: void far putimage
  619.                           (int left, int top, void far *bitmap, int op);
  620.  
  621.         PutImage works as before, with the exception that the copying 
  622.         methods have been expanded to allow 24 different copying methods. 
  623.         For more information on the copying methods available, refer to 
  624.         the SetWriteMode function.
  625.  
  626.         See also:
  627.            ImageSize, GetImage, SetWriteMode
  628.  
  629.         ---------------------------------------------------------------
  630.  
  631.         Pascal: function RegisterBGIdriver(Driver : pointer) : integer;
  632.         C, C++: int registerbgidriver(void (*driver)(void));
  633.  
  634.         The RegisterBGIdriver function allows you to link the BGI driver 
  635.         directly into the program. Either loaded on the heap, or as a 
  636.         linked in code module. You do not need to normally call this 
  637.         function unless you want to provide the BGI driver as a part of 
  638.         your program. Normally the InitGraph procedure will read the BGI 
  639.         driver from the disk and install it on the heap unless you 
  640.         override it with the RegisterBGIdriver function. 
  641.  
  642.         To over-ride the InitGraph function, load the BGI driver into 
  643.         your program. Either as a part of the compile process via the 
  644.         Link directive, or by loading the BGI driver yourself directly 
  645.         into memory. Then use the RegisterBGIdriver to provide the 
  646.         InitGraph routine with a pointer to the start of the BGI driver 
  647.         image. 
  648.  
  649.         See also:
  650.           DetectGraph, InitGraph, InstallUserDriver
  651.  
  652.         -----------------------------------------------------------------
  653.  
  654.         Pascal: procedure SetActivePage(Page : word);
  655.         C, C++: void far setactivepage(int page);
  656.  
  657.         The SetActivePage does nothing. You only get one display page to 
  658.         work with. If you want more you are welcome to add it to the BGI 
  659.         code.
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.  
  667.  
  668.  
  669.  
  670.  
  671.                                        11
  672.  
  673.  
  674.  
  675.         -----------------------------------------------------------------
  676.  
  677.         Pascal: procedure SetAllPalette(var Palette);
  678.         C, C++: void far setallpalette(struct palettetype far *palette);
  679.  
  680.         This is an EGA type function. You can only set the first 16 
  681.         palette entries with this function. It is recommended that you 
  682.         do not use this function. Use the SetRBGpalette function instead. 
  683.         The function is mainly here for compatibility.
  684.  
  685.         See also: 
  686.           GetDefaultPalette, GetPalette, SetPalette, SetRGBpalette
  687.  
  688.         -----------------------------------------------------------------
  689.  
  690.         Pascal: procedure SetBkColor(ColorNum:word); 
  691.         C, C++: void far setbkcolor(int color);
  692.  
  693.         SetBkColor is an EGA type function. SetBkColor sets the color for 
  694.         palette zero. It is limited to copying the color from the palette 
  695.         number passed in the function. You are not passing a true color 
  696.         value, rather you are passing a reference to the palette number 
  697.         you wish to copy the color from. The background color will become 
  698.         the same color as that used by the palette number that you 
  699.         referenced.  
  700.  
  701.         Since this is an EGA only function, it is limited to access of 
  702.         the first 16 palette entries. It is recommended that you use the 
  703.         SetRGBPalette function to set the background color for palette 
  704.         zero. Palette zero is the default background palette.
  705.         The function is mainly here for compatibility.
  706.  
  707.         See also:
  708.           GetBkColor, SetColor, GetColor, SetWriteMode, GetMaxColor
  709.  
  710.         -----------------------------------------------------------------
  711.  
  712.         Pascal: procedure SetColor(ColorNum:word); 
  713.         C, C++: void far setcolor(int color);
  714.  
  715.         SetColor works just like it normally does with the exception that
  716.         you can specify any of the 256 possible colors. You can also use 
  717.         the SetColor function to set the background drawing color. This 
  718.         is done by setting the current drawing color to the desired 
  719.         background color to use with the SetColor function, then using 
  720.         the SetWriteMode function to make it the new background drawing 
  721.         color. See the SetWriteMode function for more detail. To define 
  722.         the color that will be selected by the SetColor function, see the 
  723.         SetRGBPalette function.
  724.  
  725.         See also:
  726.           GetColor, SetWriteMode, GetMaxColor, SetRGBPalette, SetBkColor
  727.  
  728.  
  729.  
  730.  
  731.  
  732.                                        12
  733.  
  734.  
  735.  
  736.         ---------------------------------------------------------------
  737.  
  738.         Pascal: procedure SetGraphMode(Mode : integer);
  739.         C, C++: void far setgraphmode(int mode);
  740.  
  741.         The SetGraphMode function sets the display mode to the value 
  742.         provided. The mode number must be in the range of available 
  743.         modes (less than or equal to the maximum mode available as 
  744.         determined by the GetMaxMode function. Refer to the mode listing 
  745.         for the various mode numbers available.
  746.  
  747.         See also:
  748.           GetMaxMode, GetGraphMode, GetModeName
  749.  
  750.         -----------------------------------------------------------------
  751.  
  752.         Pascal: procedure SetPalette(ColorNum : word; Color : shortint);
  753.         C, C++: void far setpalette(int colornum, int color);
  754.  
  755.         This is an EGA type function. You can only set the first sixteen 
  756.         palettes using this function in the EGA fashion. It is 
  757.         recommended that you do not use this function. You should use the 
  758.         SetRGBpalette function instead. The function is mainly here for 
  759.         compatibility.
  760.  
  761.         See also: 
  762.           GetDefaultPalette, GetPalette, SetAllPalette, SetRGBpalette
  763.  
  764.         -----------------------------------------------------------------
  765.  
  766.         Pascal: procedure SetRGBPalette
  767.                    (ColorNum, RedValue, GreenValue, BlueValue : integer);
  768.         C, C++: void far setrgbpalette
  769.                    (int colornum, int red, int green, int blue);
  770.  
  771.         This is the correct function to use to set the palette colors in 
  772.         the BGI driver. It works just as the manual says it does. You can 
  773.         set any of the 256 palettes using this function. There is no 
  774.         associated GetRGBPalette function, but you can perform the 
  775.         function with a small assembler code fragment as show below:
  776.  
  777.         GetRGBPalette:
  778.              MOV  AX,1015H
  779.              MOV  BX,[ColorNumber]
  780.              INT  10H
  781.              MOV  [RedValue],DH
  782.              MOV  [GreenValue],CH
  783.              MOV  [BlueValue],CL
  784.  
  785.         See also: 
  786.           GetDefaultPalette, GetPalette, SetAllPalette, SetPalette
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.                                        13
  794.  
  795.  
  796.  
  797.         -----------------------------------------------------------------
  798.  
  799.         Pascal: procedure SetVisualPage(Page : word);
  800.         C, C++: void far setvisualpage(int page);
  801.  
  802.         The SetVisualPage does nothing. You only get one display page to 
  803.         work with. If you want more you are welcome to add it to the BGI 
  804.         code.
  805.  
  806.         -----------------------------------------------------------------
  807.  
  808.         Pascal: procedure SetWriteMode(WriteMode : integer);
  809.         C, C++: void far setwritemode(int mode);
  810.  
  811.         The SetWriteMode function has been altered. Normally it only 
  812.         allows the values of 0 and 1 to be used. It has been modified to 
  813.         expand the available write modes and to provide a means to also 
  814.         control the write mode of the pixel, bar, fill, and text 
  815.         routines. 
  816.  
  817.         See SetWriteMode Operation description below for a description on 
  818.         the use of the SetWriteMode command. Also see the FLOOD.DOC file 
  819.         for a description of the floodfill operation.
  820.  
  821.         See also:
  822.           SetColor, GetColor, SetBkColor, GetBkColor, SetRGBPalette
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.                                        14
  855.  
  856.  
  857.  
  858.                              SetWriteMode Operation
  859.  
  860.         The top three bits (5, 6 and 7) of the WriteMode value controls 
  861.         which group of functions the write mode value will affect. 
  862.  
  863.         Bits 5, 6 and 7 = function select:
  864.           000 = 0:(00) Line procedures
  865.           001 = 1:(20) Pixel procedures 
  866.           010 = 2:(40) Fill procedures
  867.           011 = 3:(60) Floodfill options
  868.           100 = 4:(80) Text procedures
  869.           101 = 5:(A0) <reserved>
  870.           110 = 6:(C0) GetImage procedures
  871.           111 = 7:(E0) Misc commands 
  872.  
  873.         If the function select value is 000 ($00), the Line function 
  874.         write mode will be updated. All line based functions are 
  875.         controlled via this setting. 
  876.  
  877.         If the function select value is 001 ($20), the Pixel 
  878.         function write mode will be updated. All pixel based functions 
  879.         are controlled via this setting. (This includes circle and arc 
  880.         drawing.)
  881.  
  882.         If the function select value is 010 ($40), the bar/fill 
  883.         write mode function will be updated. All Bar and fill functions 
  884.         will be affected by this setting (this includes floodfill). 
  885.  
  886.         If the function select value is 011 ($60), the floodfill 
  887.         type options will be updated. Future floodfill operations will 
  888.         then be perfromed in the manner specified.
  889.  
  890.         If the function select value is 100 ($80), the text write mode 
  891.         function will be updated. All bitmapped text functions will be 
  892.         drawn using the mode specified. 
  893.  
  894.         Function select value 101 ($A0) is reserved for future use. 
  895.  
  896.         If the function select value is 110 ($C0), the Image write mode 
  897.         function will be updated. When the GetImage function is modified 
  898.         for read/write operation the image write will be drawn using the 
  899.         mode specified. Note that a call to PutImage will override any 
  900.  
  901.         If the value is 111 ($E0), then a misc command function is 
  902.         performed. See the list below for the specific commands that are 
  903.         currently supported for this selection.
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.                                        15
  916.  
  917.  
  918.  
  919.         Functions $00, $20, $40, and $80 use the following mode commands 
  920.         to control the operation of the selected function.
  921.  
  922.         Bits 0-4 = write mode:
  923.          foreground and       foreground              background 
  924.          background drawing   drawing only            drawing only
  925.           0= MOVE write       8= FORE MOVE write      16= BACK MOVE write     
  926.           1= XOR write        9= FORE XOR write       17= BACK XOR write      
  927.           2= OR write        10= FORE OR write        18= BACK OR write      
  928.           3= AND write       11= FORE AND write       19= BACK AND write     
  929.           4= NOT MOVE write  12= FORE NOT MOVE write  20= BACK NOT MOVE write
  930.           5= NOT XOR write   13= FORE NOT XOR write   21= BACK NOT XOR write 
  931.           6= NOT OR write    14= FORE NOT OR write    22= BACK NOT OR write  
  932.           7= NOT AND write   15= FORE NOT AND write   23= BACK NOT AND write 
  933.  
  934.         24 = Set Background color to currently selected foreground color.
  935.         30 = Return the current write mode on next GetMaxMode call.
  936.         31 = Return selected background color on next GetMaxMode call.
  937.  
  938.         Bits 0 through 4 control the write mode that will be used. 
  939.         If the value given is between 0 and 7, then both the foreground 
  940.         and the background will be drawn using the style selected. 
  941.  
  942.         If a value between 8 and 15 is used, then only the foreground 
  943.         will be drawn using the style selected. The background will be 
  944.         left unaffected. 
  945.  
  946.         If a value between 16 and 23 is given, then only the background 
  947.         will be drawn using the style selected. The foreground will be 
  948.         left unaffected. 
  949.  
  950.         Value 24 is used to set the background color for the selected 
  951.         function. The current drawing color that was set with SetColor 
  952.         will be used as the background color for the selected function.
  953.  
  954.         Values 25 through 29 are currently reserved for future use and 
  955.         should not be used. 
  956.  
  957.         Value 30 modifies the GetMaxMode function so that it will return 
  958.         the currently selected write mode on the next call.
  959.  
  960.         Value 31 modifies the GetMaxMode function so that it will return 
  961.         the currently selected background color on the next call.
  962.  
  963.         Note that the values between 0 and 23 are all valid for 
  964.         controlling with the PutImage function as well. Use the desired 
  965.         value as the WriteMode value in the PutImage function. The 
  966.         PutImage background color is controlled via the Misc Command 
  967.         selection (see below).
  968.  
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.                                        16
  977.  
  978.  
  979.  
  980.         The FloodFill type option selection ($60) allows you to control 
  981.         the operation of the floodfill procedure. The following options 
  982.         are currently supported.
  983.  
  984.           BorderFill ------- 0  = border fill method (default)
  985.           SeedFill --------- 1  = seed fill method
  986.           AutoFill --------- 8  = auto fill mode detection (default)
  987.           ComplexFill ------ 9  = force complex fill mode
  988.           FillCompressOff -- 10 = fast fill stack operation (default)
  989.           FillCompressOn --- 11 = compressed fill stack operation
  990.           FillDelayOff ----- 12 = draw fill lines during search (default)
  991.           FillDelayOn ------ 13 = wait until search is done to do fill
  992.           FillTracerOff ---- 14 = don't show tracer cursor (default)
  993.           FillTracerOn ----- 15 = show tracer cursor during search
  994.  
  995.         Sub-functions 2-7 and 16-30 are currently unused and reserved for 
  996.         future use. You should not use these function numbers.
  997.  
  998.         Sub-function 31 returns the currently selected floodfill option 
  999.         flags in the next GetMaxMode function call. 
  1000.  
  1001.         The format of the option flags is as follows:
  1002.          bit        description
  1003.           0: 0=borderfill    1=seedfill
  1004.           1: <reserved>
  1005.           2: 0=auto fill     1=force complex fill
  1006.           3: 0=compress off  1=compress on
  1007.           4: 0=delay off     1=delay on
  1008.           5: 0=tracer off    1=tracer on
  1009.           6: <reserved>
  1010.           7: 0=simplex fill  1=complex fill
  1011.  
  1012.         For more information of the operation of the floodfill function, 
  1013.         see the FLOOD.DOC file which contains a full description of the 
  1014.         operation of the floodfill function.
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021.  
  1022.  
  1023.  
  1024.  
  1025.  
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031.  
  1032.  
  1033.  
  1034.  
  1035.  
  1036.  
  1037.                                        17
  1038.  
  1039.  
  1040.  
  1041.         The Misc Command selection ($E0) controls various misc internal 
  1042.         operations of the BGI driver. The following options are 
  1043.         currently supported by this selection.
  1044.  
  1045.          0 - Restore GetPixel to Read only functionality
  1046.          1 - Alter GetPixel to Write current color after reading
  1047.          2 - Restore GetImage to Read only functionality
  1048.          3 - Alter GetImage to exchange image between memory and display
  1049.         24 - Set PutImage background color to the current color that was 
  1050.               selected with the SetColor function.
  1051.         25 - Return the currently active Display mode on the next            
  1052.               GetMaxMode call. 
  1053.         26 - Return the peak stack usage of the last floodfill command                              
  1054.               that was performed on the next GetMaxMode call. 
  1055.         27 - Return the free stack space of the last floodfill command                              
  1056.               that was performed on the next GetMaxMode call. 
  1057.         30 - Return the last used PutImage write mode on the next 
  1058.               getMaxMode call.
  1059.         31 - Return PutImage background color on next GetMaxMode call. 
  1060.  
  1061.         Sub-functions 4-23 and 28-29 are currently unused and reserved 
  1062.         for future use. You should not use these function numbers.
  1063.  
  1064.  
  1065.  
  1066.  
  1067.  
  1068.  
  1069.  
  1070.  
  1071.  
  1072.  
  1073.  
  1074.  
  1075.  
  1076.  
  1077.  
  1078.  
  1079.  
  1080.  
  1081.  
  1082.  
  1083.  
  1084.  
  1085.  
  1086.  
  1087.  
  1088.  
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.                                        18
  1099.  
  1100.  
  1101.  
  1102.         Note that unlike the BGI drivers supplied by Borland, this BGI 
  1103.         driver allows you to change the palette used for the background 
  1104.         at will. This allows you to set a specific background color for 
  1105.         the object you are drawing without affecting the backgrounds of 
  1106.         all other drawn items on the screen. 
  1107.  
  1108.         In effect, this means that all drawing takes place with both a 
  1109.         foreground color and a background color that you can specify. 
  1110.         As an example, to set the Fill background color for all following 
  1111.         fill commands you would do it like this in Pascal:
  1112.  
  1113.            SetColor(BackgroundColor);
  1114.            SetWriteMode($40+24);
  1115.            SetColor(ForegroundColor);
  1116.  
  1117.         I recommend that you define some constants that contain the 
  1118.         numbers to use with the SetWriteMode function to make it clearer 
  1119.         what is being done.
  1120.  
  1121.         const LineMode   = 0;
  1122.               PixelMode  = $20;
  1123.               FillMode   = $40;
  1124.               TextMode   = $80;
  1125.               BackColor  = 24;
  1126.  
  1127.         With the above constant structure you can set the background 
  1128.         color for bitmapped text drawing to the current foreground color 
  1129.         with the instruction "SetWriteMode(TextMode+BackColor);"
  1130.  
  1131.         To make things easier, a unit called WRMODE.PAS has been included 
  1132.         which predefines the available command numbers for the 
  1133.         SetWriteMode procedure.
  1134.  
  1135.         Note: The standard BGI only uses modes 0 and 1. This new 
  1136.         SetWriteMode function does not implement modes 0 and 1 exactly 
  1137.         like the standard BGI. The standard BGI implements them as 
  1138.         foreground drawing only (mode 8). This unfortunately is 
  1139.         inconsistant with the PolyFill and BitImage operations. For 
  1140.         consistancy I have implemented the function to operate the same 
  1141.         as the BitImage and PolyFill operations. Both foreground and 
  1142.         background are written if you select mode 0 or 1. I didn't like 
  1143.         doing it, but I needed the functional code consistancy.
  1144.  
  1145.         If you wish to use the same SetWriteMode functionality, you will 
  1146.         need to use modes 8 and 9 instead of 0 and 1. In most cases the 
  1147.         differences won't be a problem, but in some cases it may, and you 
  1148.         should be aware of the difference in operation. The default line 
  1149.         write mode selection is 8 which is what the default Borland BGI 
  1150.         mode uses.
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156.  
  1157.  
  1158.  
  1159.                                        19
  1160.  
  1161.  
  1162.  
  1163.         ***************************************************************
  1164.  
  1165.         BitMapped Fonts:
  1166.  
  1167.         Another feature of the BGI256 driver is the ability to load your 
  1168.         own custom BitMapped text fonts. 
  1169.  
  1170.         The driver will by default use the low 128 character font found 
  1171.         at location $F000:$FE6A in the bios and the upper 128 character 
  1172.         font found at the address stored at the interrupt vector at $1F. 
  1173.  
  1174.         If you wish to load your own bit-mapped font for use with the 
  1175.         BGI256 driver, you can do so by loading your own 8x8 font and 
  1176.         pointing the interrupt vector at $1F to your own table. 
  1177.  
  1178.         See the BITFONT.DOC file for more information on loading your own 
  1179.         bit-mapped font for use with the BGI256 driver.
  1180.  
  1181.  
  1182.         ***************************************************************
  1183.  
  1184.         Special notes:
  1185.  
  1186.         In the previous versions of the BGI256 driver, SetWriteMode 
  1187.         function select 110 ($C0), was used to control the PutImage 
  1188.         function background color. While it is still unoffically 
  1189.         supported, it may disappear in a future release of the driver. If 
  1190.         you are using this function, you should change over to the Misc 
  1191.         Command function instead. 
  1192.  
  1193.         Note: The PutImage mode selection only worked for defining the 
  1194.         PutImage background color. When you call the PutImage function it 
  1195.         over-rides any write mode setting that was set by the 
  1196.         SetWriteMode function. For this reason, the function was dropped 
  1197.         as a group selection and the single background color selection 
  1198.         moved to the Misc command function.
  1199.  
  1200.         In the previous version of the BGI256 driver, the Group function 
  1201.         selection was ignored for subfunction value 25. While this is 
  1202.         still supported in this version of the driver, it will not be 
  1203.         supported in future versions. If you are using this function, you 
  1204.         should change it to be selected with the Misc Command group 
  1205.         selection.
  1206.  
  1207.         Also keep in mind that I am using the SetWriteMode function in an 
  1208.         unoffical way. Borland may change it's use at any point in the 
  1209.         future which may disrupt how I am using it. 
  1210.  
  1211.  
  1212.  
  1213.  
  1214.  
  1215.  
  1216.  
  1217.  
  1218.  
  1219.  
  1220.                                        20
  1221.  
  1222.  
  1223.  
  1224.         ***************************************************************
  1225.  
  1226.         Loading and using the BGI driver:
  1227.  
  1228.         You can use the RegisterBGIdriver function to register a BGI 
  1229.         driver that was directly loaded into your program. That way you 
  1230.         can avoid the delay in loading the driver from disk and the 
  1231.         possibility that the file may not be available on disk. 
  1232.  
  1233.         You can load a BGI driver into the Code segment, Data segment, or 
  1234.         onto the Heap. It is even possible to access the driver 
  1235.         externally from your program if needed. The only thing you need 
  1236.         is to pass a far pointer containing the starting location of the 
  1237.         driver image in memory to the RegisterBGIdriver function which 
  1238.         tells the program where to find the driver.
  1239.  
  1240.         By default, the Borland compilers will load the BGI driver onto 
  1241.         the heap when the InitGraph function is called. If the 
  1242.         RegisterBGIdriver function is called before the InitGraph 
  1243.         function, then the driver will be expected to exist at the 
  1244.         address provided in the pointer.
  1245.  
  1246.         If you are loading a non-Borland BGI driver, then you must 
  1247.         additionally call the InstallUserDriver function to let the 
  1248.         program know that it exists.
  1249.  
  1250.         The sequence of events should be:
  1251.  
  1252.            InstallUserDriver
  1253.            RegisterBGIdriver {if used}
  1254.            InitGraph
  1255.  
  1256.  
  1257.  
  1258.  
  1259.  
  1260.  
  1261.  
  1262.  
  1263.  
  1264.  
  1265.  
  1266.  
  1267.  
  1268.  
  1269.  
  1270.  
  1271.  
  1272.  
  1273.  
  1274.  
  1275.  
  1276.  
  1277.  
  1278.  
  1279.  
  1280.  
  1281.                                        21
  1282.  
  1283.  
  1284.  
  1285.         *****************************************************************
  1286.  
  1287.         The following are some sample procedures for initializing the
  1288.         BGI driver to show you the options that are available.
  1289.  
  1290.         {---------------------------------------------------------------}
  1291.         {Sample procedure to include the BGI256 driver in the code 
  1292.         segment and initialize it.}
  1293.  
  1294.           CONST Mode200  = 0;  {320x200x256}
  1295.                 Mode400  = 1;  {640x400x256}
  1296.                 Mode480  = 2;  {640x480x256}
  1297.                 Mode600  = 3;  {800x600x256}
  1298.                 Mode768  = 4;  {1024x768x256}
  1299.                 Mode1024 = 5;  {1280x1024x256}
  1300.  
  1301.           procedure BGI256Proc; External;
  1302.           {$L BGI256}
  1303.           procedure InitBGI256;
  1304.           begin
  1305.             GD := InstallUserDriver('BGI256',nil);
  1306.             Error := RegisterBGIdriver(@BGI256Proc);
  1307.             GM := Mode480;              {start in 640x480x256 mode}
  1308.             InitGraph(GD,GM,'');
  1309.             Error := GraphResult;
  1310.             if Error <> 0 then
  1311.             begin
  1312.               writeln(Error,' Error: Could not initialize BGI driver');
  1313.               Exit;
  1314.             end;
  1315.           end;
  1316.  
  1317.         {-----------------------------------------------------------}
  1318.         {Sample procedure to load the BGI256 driver from disk
  1319.         onto the heap and initialize it.}
  1320.  
  1321.           procedure InitBGI256;
  1322.           begin
  1323.             GD := InstallUserDriver('BGI256',nil);
  1324.             GM := Mode480;              {start in 640x480x256 mode}
  1325.             InitGraph(GD,GM,'');
  1326.             Error := GraphResult;
  1327.             if Error <> 0 then
  1328.             begin
  1329.               writeln(Error,' Error: Could not initialize BGI driver');
  1330.               Exit;
  1331.             end;
  1332.           end;
  1333.  
  1334.  
  1335.  
  1336.  
  1337.  
  1338.  
  1339.  
  1340.  
  1341.  
  1342.                                        22
  1343.  
  1344.  
  1345.  
  1346.         {-----------------------------------------------------------}
  1347.         {Sample procedure to load the BGI256 driver from disk
  1348.         onto the heap, detect whether card exists, and initialize it.}
  1349.  
  1350.           CONST AutoMode = 127;
  1351.           function BGI256AutoDetect:integer; FAR;
  1352.           begin
  1353.             BGI256AutoDetect := AutoMode; {return max mode if good}
  1354.           end;
  1355.  
  1356.           procedure InitBGI256;
  1357.           begin
  1358.             GD := InstallUserDriver('BGI256',@BGI256AutoDetect);
  1359.             InitGraph(GD,GM,'');  {GM is set by autodetect}
  1360.             Error := GraphResult;
  1361.             if Error <> 0 then
  1362.             begin
  1363.               writeln(Error,' Error: Could not initialize BGI driver');
  1364.               Exit;
  1365.             end;
  1366.           end;
  1367.  
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.  
  1392.  
  1393.  
  1394.  
  1395.  
  1396.  
  1397.  
  1398.  
  1399.  
  1400.  
  1401.  
  1402.  
  1403.                                        23
  1404.